package sky.cin.framework.sfoc.advanced.mvc;

import org.omg.PortableInterceptor.Interceptor;
import sky.cin.framework.network.filter.Filter;
import sky.cin.framework.sfoc.core.annotations.beans.Component;
import sky.cin.framework.sfoc.core.common.utils.BeanUtils;
import sky.cin.framework.sfoc.core.interfaces.BeanPostProcessor;

@Component
public class FilterSetter implements BeanPostProcessor {

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) {
        if (bean != null && BeanUtils.isAnnotationPresent(bean.getClass(), Interceptor.class)) {
            Filter.add((Filter) bean);
            return null;
        }
        return bean;
    }

}
